package cn.frh.log.controller;

import cn.frh.basic.util.AjaxResult;
import cn.frh.log.domain.LogTable;
import cn.frh.log.query.LogTableQuery;
import cn.frh.log.service.ILogTableService;
import cn.frh.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/log")
public class LogTableController {
    @Autowired
    private ILogTableService logTableService;
    @PostMapping
    public PageList<LogTable> queryPage(@RequestBody LogTableQuery query){
        return logTableService.queryPage(query);
    }
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable("id") Long id){
        try {
            logTableService.remove(id);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("骚瑞，操作失败");
        }
    }

    @PatchMapping

    public AjaxResult batchRemove(@RequestBody List<Long> ids){
        try {
            logTableService.batchRemove(ids);
            return AjaxResult.me();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setSuccess(false).setMessage("骚瑞，操作失败");
        }
    }


}
